package com.houseman.workFlow;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.houseman.workFlow.bean.ApprovalInfo;
import com.houseman.workFlow.dto.NextApprover;
import com.houseman.workFlow.service.ApproveService;
import com.houseman.workFlow.service.impl.ApproveServiceImpl;

public abstract class WorkFlowBase {

	protected int workId; //流程ID 数据库主键
	protected int step; //当前处理step
	protected String name; //流程名称
	protected String creater; //发起人
	protected boolean rollback; //是否是回退办理
	protected String action = "page"; //流程当前处理任务请求{page, approval, submit}
	protected boolean closeWindow = true; //是否关闭窗口：默认关闭
	
	//审批人组
	protected List<NextApprover> approver = new ArrayList<NextApprover>();
	
	protected HttpServletRequest request;
	protected HttpServletResponse response;
	protected HttpSession session;

	
	/**
	 * 上一步审批信息
	 * @return
	 */
	protected ApprovalInfo queryLastStepInfo() {
		ApproveService service = new ApproveServiceImpl();
		ApprovalInfo info = null;
		try {
			info = service.queryNewestByWorkId(workId);
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return info; 
	}
	
	/**
	 * 审批历史信息
	 * @return
	 */
	protected List<ApprovalInfo> queryHistoryInfo() {
		ApproveService service = new ApproveServiceImpl();
		List<ApprovalInfo> info = null;
		try {
			info = service.queryAppInfoByWorkId(workId);
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return info; 
	}
}
